//
//  XDController.m
//  XDFS
//
//  Created by Yury Soldak on 30/09/2008.
//

#import "XDController.h"
#import <MacFUSE/GMUserFileSystem.h>

#import "XDModel.h"
#import "XDFS.h"

@implementation XDController

static NSString* const kPostsURL = @"file:///Users/sky/Documents/delicious-all.xml";

- (void) applicationDidFinishLaunching:(NSNotification*) notification {  
	XDModel* model = [[XDModel alloc] initWithURLString:kPostsURL];
	NSString* mountPath = @"/Volumes/XDFS";
	XDFS* xdfs = [[XDFS alloc] initWithModel:model];
	fs = [[GMUserFileSystem alloc] initWithDelegate:xdfs isThreadSafe:YES];
	NSMutableArray* options = [NSMutableArray array];
	[options addObject:@"volname=XDFS"];
	[fs mountAtPath:mountPath withOptions:options];
}

- (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication*) sender {
	[[NSNotificationCenter defaultCenter] removeObserver:self];
	[fs unmount];
	[[fs delegate] release];
	[fs release];
	return NSTerminateNow;
}

@end
